import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import postCssPxToRem from "postcss-pxtorem";

// https://vitejs.dev/config/
export default defineConfig((mode) => {
  return {
    plugins: [vue()],
    //代理跨域/*  */
    server: {
      host: "127.0.0.1",
      port: 3000,
      proxy: {
        "/api": {
          target: "http://sph-h5-api.atguigu.cn",
          changeOrigin: true,
        },
        "/xhr": {
          target: "https://m.you.163.com",
          changeOrigin: true,
        },
        "/item": {
          target: "https://m.you.163.com",
          changeOrigin: true,
        },
        "/topic/v1": {
          target: "https://m.you.163.com",
          changeOrigin: true,
        },
      },
    },
    css: {
      postcss: {
        plugins: [
          postCssPxToRem({
            rootValue: 37.5, // 1rem的大小
            propList: ["*"], // 需要转换的属性，这里选择全部都进行转换
          }),
        ],
      },
    },
  };
});
